<%--
*
* 描述：登录文件
*
--%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<jsp:directive.page import="com.sky.common.properties.PropertiesUtils"/>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title><s:property value="getConfigValue('system_title')"/></title>
	<%@include file="/share/header.jsp"%>
	<%@include file="/share/window.jsp"%>
	<script type="text/javascript" src="<%=path%>/js/EasyCookie.min.js"></script>	
	<script type="text/javascript" src="<%=path%>/js/base64.min.js"></script>	
	<s:head/>
	<link href="<%=path%>/main/dsnc/css/login.min.css" rel="stylesheet" type="text/css">
</head>
<!--[if IE 6]>
<style type="text/css">
div.btnLogin{background-image:none;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='<%=path%>/main/dsnc/image/btn_login.png',sizingMethod="scale");}
div.btnLoginHover{background-image:none;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='<%=path%>/main/dsnc/image/btn_login_hover.png',sizingMethod="scale");}
div.btnLoginClick{background-image:none;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='<%=path%>/main/dsnc/image/btn_login_click.png',sizingMethod="scale");}
</style>
<![endif]-->
<script type="text/javascript">
	<!--
		function handleKeyDown(event){
			try{
				//var event = !event ? window.event : event;
				if(event == 13){
					onSubmit($('#login'));
				}
			}catch(e){}
		}
		function onDoLoad(){
			var base64 = new Base64();
			var rememberAccount=EasyCookie.getCookie("remember_account");
			var valueAccount=EasyCookie.getCookie("value_account");
			var rememberPassword=EasyCookie.getCookie("remember_password");
			var valuePassword=EasyCookie.getCookie("value_password");
			//alert(rememberAccount+":"+valueAccount+":"+rememberPassword+":"+valuePassword);
			if(rememberAccount!=null&&rememberAccount!=""){
				$("#remember_account").attr("checked","true");
			}
			if(valueAccount!=null&&valueAccount!=""){
				$("#account").val(base64.decode(valueAccount));
			}			
			if(rememberPassword!=null&&rememberPassword!=""){
				$("#remember_password").attr("checked","true");
			}	
			if(valuePassword!=null&&valuePassword!=""){
				$("#originalPassword").val(base64.decode(valuePassword));
			}						
		}
		function onSubmit(form){
			var result = EasyValidator.pageValidate();
			if(!result.success){//验证失败
				var messages="<br>\n";
				for(var i=0;i<result.invalidControls.length;i++){
					messages+=(i+1)+"."+result.msgs[0]+"<br>\n";
					if(i==0){//选中并聚焦到第一个失败的	
						try{//防止不能选择的报错
						    result.invalidControls[0].select();
						}catch(e){}              
						try{//防止不能聚焦的报错
						    result.invalidControls[0].focus();
						}catch(e){}  
						top.MyWindow.tips({
							content : result.msgs[0],
							title : '错误框',
							type : 'error',
							container : top,
							timer : 500					
						});										            			
		            }					
				}
				//alert(messages);					
			}else{
				loading('<br><br><img src="<%=path%>/image/loading.gif" ><br>嗨！['+$("#account").val()+']，我正在登录中，请稍候...<br><br>');
				form.target="login_<%=session.getId()%>";
				//alert($("#remember_account").attr("checked")+":"+$("#account").val());
				var base64 = new Base64(); 
				if($("#remember_account").attr("checked")){//记住用户名
					EasyCookie.setCookie("remember_account",$("#remember_account").val(),365,null,"<%=path%>");
					EasyCookie.setCookie("value_account",base64.encode($("#account").val()),365,null,"<%=path%>");
				}else{
					EasyCookie.setCookie("remember_account","",365,null,"<%=path%>");
					EasyCookie.setCookie("value_account",base64.encode(""),365,null,"<%=path%>");
				}
				//alert($("#remember_password").attr("checked")+":"+$("#originalPassword").val());
				if($("#remember_password").attr("checked")){//记住密码
					EasyCookie.setCookie("remember_password",$("#remember_password").val(),365,null,"<%=path%>");
					EasyCookie.setCookie("value_password",base64.encode($("#originalPassword").val()),365,null,"<%=path%>");
				}else{
					EasyCookie.setCookie("remember_password","",365,null,"<%=path%>");
					EasyCookie.setCookie("value_password",base64.encode(""),365,null,"<%=path%>");
				}
				var rememberAccount=EasyCookie.getCookie("remember_account");
				var valueAccount=EasyCookie.getCookie("value_account");
				var rememberPassword=EasyCookie.getCookie("remember_password");
				var vlauePassword=EasyCookie.getCookie("value_password");
				//alert(rememberAccount+":"+valueAccount+":"+rememberPassword+":"+vlauePassword);
				var account=$("#account").val();	
				var originalPassword=$("#originalPassword").val();
				if($("#encryptData").val()=="true"){//用户名和密码加密
					$("#account").val(base64.encode(account));	
					$("#originalPassword").val(base64.encode(originalPassword));
				}	
				//alert(account+":"+$("#account").val()+":"+originalPassword+":"+$("#originalPassword").val());					
				form.submit();
			}
		}
		//找回密码
		function onDoForgot(){
			var options={
				title:'【找回密码】',
				url:'<s:url action='forgot_dsnc' namespace='/main'/>',
				source : window,
				buttons:[top.MyWindow.Submit,top.MyWindow.Cancel],
				multiplewidth:1,
				multipleheight:1,
				tipstitle:'',
				tipscontent:''
			};
			top.MyWindow.open(options);
		}			
		//注册帐号
		function onDoRegister(){
			var options={
				title:'【注册帐号】',
				url:'<s:url action='register_dsnc' namespace='/main'/>',
				source : window,
				buttons:[top.MyWindow.Save,top.MyWindow.Cancel],
				multiplewidth:1,
				multipleheight:1,
				tipstitle:'',
				tipscontent:''
			};
			top.MyWindow.open(options);
		}		
	//-->
</script>
<body  onkeydown="handleKeyDown(event.keyCode)" onLoad="onDoLoad()">
<s:form id="login" action="login_dsnc" namespace="/main" validate="true" focusElement="domain.account">
<s:hidden id="encryptData" name="encryptData" value="true"/>
<div class="loginContant">
<table width="400" border="0" align="right" cellpadding="0" cellspacing="0">
  <tr>
    <td width="98" height="30" align="right" valign="middle"><strong>用户：</strong></td>
    <td width="159"><s:textfield id="textfield" id="account" name="domain.account"  label="用户名"  required="true" cssClass="loginTextInput"  theme="simple" tabindex="1"  showTip="false"/></td>
    <td width="143" rowspan="<s:property value="getConfigValue('enable_verification')==\"1\"?'3':'2'"/>" align="left" valign="middle"><div class="btnLogin" onClick="onSubmit($('#login'))" onMouseOver="this.className='btnLoginHover'" onMouseOut="this.className='btnLogin'" tabindex="4"></div>
    <span style="float: left; margin-left: 5px; margin-top: 15px;">
       <s:if test="getConfigValue('find_password')==\"1\"">
         <a href="javascript:onDoForgot();" title="找回密码">找回密码</a>
       </s:if>  
       <br>
       <s:if test="getConfigValue('register_account')==\"1\"">
         <a href="javascript:onDoRegister();" title="注册帐号">注册帐号</a>
       </s:if>       
    </span>
    </td>
  </tr>
  <tr>
    <td height="30" align="right" valign="middle"><strong>密码：</strong></td>
    <td>
    <s:password id="originalPassword"   name="domain.originalPassword"  label="登录密码" showPassword="true"  required="true" cssClass="loginTextInput"  theme="simple" tabindex="2" showTip="false" autocomplete="off"/>
    </td>
   </tr>
   <s:if test="getConfigValue('enable_verification')==\"1\"">
   <tr>
    <td height="30" align="right" valign="middle"><strong>验证码：</strong></td>
    <td >
     <s:textfield id="textfield" id="verification" name="verification"  label="验证码"  value="" required="true" cssClass="verificateTextInput" length="4" theme="simple" tabindex="3" showTip="false"/>
     <img  align="absmiddle" src="<s:url action="verificationImage" namespace="/main"/>" width="60" height="20" onclick="this.src='<s:url action="verificationImage" namespace="/main"/>?d='+new Date().getTime();" alt="请点击更换验证码图片">
    </td>   
   </tr> 
   </s:if>
   <tr>
    <td></td>
    <td colspan="2">
       <table  width="55%" border="0" align="left" cellpadding="0" cellspacing="0">
        <tr>
          <td height="30">
          <s:if test="getConfigValue('remember_account')==\"1\"">
              <input type="checkbox" id="remember_account" name="remember_account" value="1"/><label for="remember_account">记住用户</label>
          </s:if>    	
          </td>
          <td>
          <s:if test="getConfigValue('remember_password')==\"1\"">
              <input type="checkbox" id="remember_password" name="remember_password" value="2"/><label for="remember_password">记住密码</label>
          </s:if>
          </td>
         </tr>
       </table>   
    </td>
   </tr>
   <tr>
    	<td colspan="100" align="left" style="padding-right: 30px;">
			<s:actionerror/>
		</td>
	</tr>
</table>
</div>
</s:form>
<div class="copyRight">
	版权所有©<s:property value="getConfigValue('copyright')"/><br />
	研发单位：<s:property value="getConfigValue('research_organization')"/><br />
	技术支持：<a href="<s:property value="getConfigValue('supporte_website')"/>" target="_blank"><s:property value="getConfigValue('supporte_organization')"/></a><br />
	支持电话：<s:property value="getConfigValue('supporte_telephone')"/><br />
	支持邮箱：<s:property value="getConfigValue('supporte_email')"/><br />
	当前版本：<s:property value="getConfigValue('version')"/><br />
	<a target="blank" href="http://wpa.qq.com/msgrd?V=1&Uin=<s:property value="getConfigValue('supporte_qq')"/>&Menu=yes" title="点击这里给我发消息"><img border="0" src="<%=path%>/main/dsnc/image/qq.png" width="20" height="20" align="absmiddle"><sapn style="line-height:20px;">QQ留言</span></a>	
</div>
</body>
</html>